<tagLib name="html" />
<include file="Public:header" />
<script src="__PUBLIC__/Js/jquery-1.4.4.min.js"></script>
<!--
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
-->
<css href="__PUBLIC__/Css/ui-base/jquery.ui.all.css" />
<script src="__PUBLIC__/Js/jquery-ui-1.8.11.custom.min.js"></script>
<div id="main" class="main" >
<script language="JavaScript">
<!--
jQuery(document).ready(function(){
    $('#totalprice').click(
    function (){
        var amount = $(':checkbox[name:room_id]:checked').length;
        var house_id = $('#house_id').val();
        var start_time = $("input[name='start_time']").val();
        var end_time = $("input[name='end_time']").val();
        $('#room_num').attr('value', amount);
        jQuery.post(URL+'/calPrice',
        {house_id:house_id,
         amount:amount,
         start_time:start_time,
         end_time:end_time
        },
        function(msg){
            $('#totalprice').attr('value',msg);
        },
        'text')
    }
    );

     $( "#member_name" ).autocomplete({
			source: URL+"/getAllMember",
			minLength: 1,
			select: function( event, ui ) {
				//log( ui.item ?"Selected: " + ui.item.value + " aka " + ui.item.id :"Nothing selected, input was " + this.value );
                                $('#member_id').attr('value',ui.item.id);
                    }
		});
}
);
function showdetail(obj){
        var order_id = obj.value;
        if(order_id > 0){
        jQuery.post(
        URL+'/getMemberByOrder',
        {order_id:order_id},
        function(data){
            data = data.data;
            $('#member_id').attr('value',data.member_id);
            $('#member_name').attr('value',data.member);
            $("input[name='start_time']").attr('value',data.start_time);
            $("input[name='end_time']").attr('value',data.end_time);
            $('#person_name').attr('value',data.cust_name+',');
            $('#advance_pay').attr('value',data.advance_pay);
            $('#house_td').empty();
            $('#house_td').append('<input type="text" name="house" id="house">');
            $('#house').attr('value',data.house);
            $('#room_td').empty();
            $('#room_td').append(data.rooms);
        },
        'json'
        );
        }
        else{
            $('#member_id').attr('value',0);
            $('#member_name').attr('value','无');
            $('#house_td').empty();
            $('#house_td').append(
                '<select name="hotel" style="width:200px;" onchange="modifyHouse(this);"><option value="0">--请选择公寓--</option><volist name="hotel" id="ht"><option value="{$ht.id}">{$ht.name}</option></volist></select>{$vo.house_id|makeHouse=1}'
            );
        }
};
$(function() {
		var availableTags = [
			<volist name="member" id="pe">
                        "{$pe.name}",
                        </volist>
		];
		function split( val ) {
			return val.split( /,\s*/ );
		}
		function extractLast( term ) {
			return split( term ).pop();
		}

		$( "#person_name_0000" )
			// don't navigate away from the field on tab when selecting an item
			.bind( "keydown", function( event ) {
				if ( event.keyCode === $.ui.keyCode.TAB &&
						$( this ).data( "autocomplete" ).menu.active ) {
					event.preventDefault();
				}
			})
			.autocomplete({
				minLength: 1,
				source: function( request, response ) {
					// delegate back to autocomplete, but extract the last term
					response( $.ui.autocomplete.filter(
						availableTags, extractLast( request.term ) ) );
				},
				focus: function() {
					// prevent value inserted on focus
					return false;
				},
				select: function( event, ui ) {
					var terms = split( this.value );
					// remove the current input
					terms.pop();
					// add the selected item
					terms.push( ui.item.value );
					// add placeholder to get the comma-and-space at the end
					terms.push( "" );
					this.value = terms.join( ", " );
					return false;
				}
			});
	});
//-->
</script>
<div class="content">
<form method='post' id="form1" action="__URL__/insert/" >
<div class="title">新增入住单 [ <input type="submit" value="新 增" class="small submit"> <a href="__URL__">返回入住单列表</a>    <a href="__APP__/Housestats">返回房态</a>]</div>
<table cellpadding=3 cellspacing=3>
    <tr>
        <td class="tRight" >预订单号：</td>
        <td class="tLeft" >
    <notempty name="_GET.orderid">
         <input type="hidden"  name="order_id" value="{$_GET.orderid}">{$_GET.orderid|getModelName='Order','order_no'}
        <else/>
            <select name="order_id" onchange="showdetail(this);">
                <option value="0">--无预订单号--</option>
                <volist name="orders" id="od">
                    <option value="{$od.id}">{$od.order_no} ({$od.member_id|getModelName='Member'} )</option>
                </volist>
            </select>
    </notempty>
        </td>
    </tr>
    <tr>
        <td class="tRight" ><span class="red">*</span>预订人：</td>
        <td class="tLeft" >
            <input type="hidden" name="member_id" id="member_id" <notempty name="_GET.orderid">value="{$_GET.orderid|getModelName='Order','member_id'}"</notempty> >
            <input class="huge" type="text" id="member_name" name="member_name"
            <notempty name="_GET.orderid"> value="{$_GET.orderid|getModelName='Order','member_id'|getMemberFullName}"</notempty>>输入两个字符以上自动提示
        </td>
    </tr>
<tr>
	<td class="tRight" >房型：</td>
	<td class="tLeft" id="house_td">
            <notempty name="_GET.room_id">{$_GET.room_id|getModelName=Room,house_id|getModelName=House}
                <input type="hidden" name="house_id" id="house_id" value="{$_GET.room_id|getModelName=Room,house_id}">
                <else />
            <select name="hotel" style="width:200px;" onchange="modifyHouse(this);">
                        <option value="0">--请选择公寓--</option>
                        <volist name="hotel" id="ht">
                            <option value="{$ht.id}">{$ht.name}</option>
                        </volist>
                    </select>
                    {$vo.house_id|makeHouse=1}
            </notempty>
            <notempty name="_GET.orderid">
                该预订单的房型为：{$_GET.orderid|getModelName="Order",'house_id'|getModelName='House'} {$_GET.orderid|getModelName="Order",'room_id'|getRoomNo}
            </notempty>
        </td>
</tr>
<tr id="room_tr">
    <td class="tRight" ><span class="red">*</span>入住房间：</td>
	<td class="tLeft" id="room_td">
            <notempty name="_GET.room_id">
                <input type="radio" id="room_id" name="room_id" value="{$_GET.room_id}" checked>{$_GET.room_id|getModelName=Room,room_no}
                <else />
            <input type="radio" id="room_id">
            </notempty>
        </td>
</tr>
<load href="__PUBLIC__/Js/My97DatePicker/WdatePicker.js" />
<tr>
	<td class="tRight" ><span class="red">*</span>入住：</td>
	<td class="tLeft" ><input type="text"  onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" name="start_time" id="start_time1" value="<notempty name='_GET.start_time'>{$_GET.start_time}</notempty>">
             &nbsp;&nbsp;<span class="red">*</span>离开：
            <input type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" name="end_time" id="end_time" value="<notempty name='_GET.end_time'>{$_GET.end_time}</notempty>">
             &nbsp;&nbsp;实际离开：
            <input type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" name="end_realtime" id="end_realtime" value="">
        </td>
</tr>
<tr>
	<td class="tRight" ><span class="red">*</span>入住人：</td>
	<td class="tLeft" >
            <input type="text" class="huge" id="person_name" name="person_name" <notempty name="_GET.orderid"> value="{$_GET.orderid|getModelName='Order','member_id'|getMemberFullName}"</notempty>>输入两个字符以上自动提示
        </td>
</tr>
<tr>
	<td class="tRight" >入住人数：</td>
	<td class="tLeft" >
            <input type="text" class="medium bLeft" name="person_num" value=""></td>
</tr>
    <tr>
	<td class="tRight" >预付款：</td>
	<td class="tLeft" ><input type="text" class="medium bLeft" name="advance_pay" id="advance_pay" value=""></td>
</tr>
<tr>
	<td class="tRight" >押金：</td>
	<td class="tLeft" ><input type="text" class="medium bLeft" name="deposit" id="deposit"></td>
</tr>
<tr>
	<td class="tRight" >已消费金额：</td>
	<td class="tLeft" ><input type="text" class="medium bLeft" name="cost_pay" value=""></td>
</tr>
<tr>
	<td class="tRight" >结帐时间：</td>
	<td class="tLeft" ><input type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" name="balance_time" value=""></td>
</tr>
<tr>
	<td class="tRight" >结帐金额：</td>
	<td class="tLeft" ><input type="text" class="medium bLeft" name="banlance_money" value=""></td>
</tr>

<tr>
	<td class="tRight tTop">备注说明：</td>
	<td class="tLeft"><textarea class="large bLeft"  name="remark" rows="5" cols="57"></textarea></td>
</tr>
<tr>
	<td class="tRight">状态：</td>
	<td class="tLeft">
            <select class="middle bLeft"  name="status">
                <volist name="checkinStatus" id="stvo">
                    <option value="{$key}">{$stvo}</option>
                </volist>
            </select> &nbsp;&nbsp;提醒时间：<input type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="medium bLeft" name="alert_time" value="">
        </td>
</tr>
<tr>
	<td></td>
	<td class="center">
	<input type="submit" value="保 存" class="small submit">
	<input type="reset" class="reset imgButton" onclick="javascript:history.back()" value="返回" >
	</td>
</tr>
</table>
</form>

</div>
</div>